package Simulator;

import java.util.LinkedList;
import java.util.List;
import Shared.MapPosition;


/**
 * Main object used to launch the Simulator part.
 */

public class Simulator {

	/**
	 * Starts every thread needed to run the Simulator part.
	 * 
	 * @return a list of all started threads
	 */
	public synchronized List<Thread>  startSimulation() {

		EnvironmentDatabase db = EnvironmentDatabase.getInstance();

		db.addHospital(new MapPosition(525, 175));
		db.addHospital(new MapPosition(200, 400));
		
		AmbulanceSimulator ambSimulator = AmbulanceSimulator.getInstance();
				
		GUI gui = new GUI();
		
		Thread TWitness = new Thread(new Witness());
		Thread TAmbMngr = new Thread(ambSimulator);		
		Thread TGui = new Thread(gui);

		TWitness.setName("Witness");
		TWitness.start();
		TAmbMngr.setName("AmublanceManager");
		TAmbMngr.start();
		TGui.setName("GUI");
		TGui.start();
		
		LinkedList<Thread> list = new LinkedList<Thread>();
		list.add(TWitness);
		list.add(TAmbMngr);
		list.add(TGui);
		
		return list;
	}

	/**
	 * Starts startSoftware();
	 * 
	 * @param args
	 *            not used
	 */
	public static void main(String[] args) throws InterruptedException {
		(new Simulator()).startSimulation();
	}

}
